
clear all
set more off

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"

cd "`path0'Data\IPUMS_1970"

use step300, clear
gen lnage=(age)
gen lnage2=lnage^2

rename science_occupation so
rename science_occupationA soA

drop e_GBR

foreach mm in so  {
*================================================================
*** control for basic exo vars + level of education for US-born
*** WEIGHTED
*================================================================

xi: reg  `mm' e_* lnage lnage2 i.educd [aw=perwt]

gen coef1_`mm'=0 if countrycode=="GBR"
gen se1_`mm'=0 if countrycode=="GBR"

quiet foreach var in ///
		AGO ALB  ARE ARG AUS AUT BEL BFA BGD BGR BRA BTN CAN ///
		CHE CHL CHN COL CRI CZE DNK DOM ECU EGY ESP EST ETH FIN ///
		FJI FRA GER GHA GRC GTM HND HRV HUN IDN IND IRL IRN ///
		IRQ ISL ISR ITA JAM JOR JPN KEN KOR KWT LBN LBY LKA LTU LUX ///
		LVA MAR MEX MLT MOZ MWI MYS NAM NGA NLD NOR NPL NZL PAK PAN ///
		PER PHL POL PRT ROM RUS SAU SCG SEN SLE SLV SVK SVN SWE ///
		SYR THA TTO TUR TWN TZA UKR URY VEN VNM ZAF ZMB  ///
		{
		
capture replace coef1_`mm'=_b[e_`var'] if countrycode=="`var'" & e(sample)
capture replace se1_`mm'=_se[e_`var'] if countrycode=="`var'" & e(sample)

}

gen count1_`mm'=coef1_`mm'


*====================================================================
* 		Only persons with Bachelor and higher degree
*====================================================================
xi: reg  `mm' e_*   lnage lnage2 i.educd [aw=perwt] if educd>=100

gen coef3_`mm'=0 if countrycode=="GBR"
gen se3_`mm'=0 if countrycode=="GBR"

quiet foreach var in ///
		AGO ALB  ARE ARG AUS AUT BEL BFA BGD BGR BRA BTN CAN ///
		CHE CHL CHN COL CRI CZE DNK DOM ECU EGY ESP EST ETH FIN ///
		FJI FRA GER GHA GRC GTM HND HRV HUN IDN IND IRL IRN ///
		IRQ ISL ISR ITA JAM JOR JPN KEN KOR KWT LBN LBY LKA LTU LUX ///
		LVA MAR MEX MLT MOZ MWI MYS NAM NGA NLD NOR NPL NZL PAK PAN ///
		PER PHL POL PRT ROM RUS SAU SCG SEN SLE SLV SVK SVN SWE ///
		SYR THA TTO TUR TWN TZA UKR URY VEN VNM ZAF ZMB  ///
		{
		
capture replace coef3_`mm'=_b[e_`var'] if countrycode=="`var'" & e(sample)
capture replace se3_`mm'=_se[e_`var'] if countrycode=="`var'" & e(sample)

}
gen count3_`mm'=coef3_`mm'


}

collapse (mean) idv coef* se* (count) count*_*, by(countrycode)
save step302_all_people, replace


